<template>
  <div class="hello">
    <ul>
      <li v-for="(item, index) in list" :key="index">
        {{ item.name }}==年龄{{ item.age }}
        <span @click="remove(index)">x</span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "HelloWorld",

  computed: {
    username() {
      return this.$store.state.username;
    },
    list() {
      return this.$store.state.list;
    },
  },
  methods: {
    remove(index) {
      this.$store.commit("remove", index);
    },
    //commit 调用仓库里的mutations方法的 第一个参数是mutations 的名字 第二参数是传递的参数
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss"></style>
